import Vue from 'vue'
//配置路由相关的信息VueRouter
import VueRouter from 'vue-router'
import Home from '../views/home/Home.vue'
import Category from '../views/category/Category.vue'
import Cart from '../views/cart/Cart.vue'
import Profile from '../views/profile/Profile.vue'

// const Home = () => import('../views/home/Home')
// const Category = () => import('../views/category/Category')
// const Cart = () => import('../views/cart/Cart')
// const Profile = () => import('../views/profile/Profile')
//安装插件
Vue.use(VueRouter)

//创建路由router
const routes = [
  {
    path: '',
    // redirect重定向
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home
  },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // },
  {
    path: '/category',
    component: Category
    // component: () => import(/* webpackChunkName: "about" */ '../views/category/Category.vue')
  },
  {
    path: '/cart',
    component: Cart
  },
  {
    path: '/profile',
    // name: 'Profile',
    component: Profile
  }

]
// 创建VueRouter对象
const router = new VueRouter({
  // 去掉哈希模式
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
